package com.lynkin.realizedream.controller;

import com.lynkin.realizedream.entity.DoubleColorBall;
import com.lynkin.realizedream.service.RealizeDreamService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author lingjian
 * @description: TODO
 * @date 2022/4/2 13:04
 */
@RestController
@RequestMapping("/realizeDream")
public class RealizeDreamController {

    @Autowired
    private RealizeDreamService realizeDreamService;

    @GetMapping("/getMysteriousCode")
    public String getMysteriousCode() {
        List<DoubleColorBall> doubleColorBalls = realizeDreamService.oldCodes();
        DoubleColorBall doubleColorBall = new DoubleColorBall();
        if (doubleColorBalls != null && doubleColorBalls.size() != 0) {
            doubleColorBall = doubleColorBalls.get(0);
        }
        String content = "";
        if (ObjectUtils.isNotEmpty(doubleColorBall)) {
            content = "上期回顾：" + doubleColorBall.getPeriod_Id() + "期：红球："
                    + doubleColorBall.getRedBall_One()
                    + "," + (doubleColorBall.getRedBall_Two() == 0 ? 12 : doubleColorBall.getRedBall_Two())
                    + "," + doubleColorBall.getRedBall_Three()
                    + "," + doubleColorBall.getRedBall_Four()
                    + "," + doubleColorBall.getRedBall_Fives()
                    + "," + doubleColorBall.getRedBall_Six()
                    + "  蓝球：" + doubleColorBall.getBlueBall_One()
                    + "   本期一等奖号码：";
        }

        return content  + realizeDreamService.getMysteriousCode();
    }

}
